package com.qqbot.impl.task;

import com.qqbot.core.core.Bot;
import com.qqbot.core.core.BotFactory;
import com.qqbot.core.message.MessageChain;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * qq飞车上号
 *
 * @author changwenpeng
 * @date 2022年5月9日
 */
@Component
public class RobotTaskShangHao {

    /**
     * qq飞车登录
     *
     * @throws Exception
     */
    @Scheduled(cron = "10 58 14 * * ?")
    public void shanghao() throws Exception {
        this.sendMorningAndNight(new MessageChain().text("上号电信全部任务"));
    }

    /**
     * 发送消息
     *
     * @param mc
     * @throws Exception
     */
    private void sendMorningAndNight(MessageChain mc) throws Exception {
        List<Bot> botList = BotFactory.getBots();
        if (CollectionUtils.isEmpty(botList)) {
            return;
        }
        Bot bot = botList.get(0);
        bot.sendGroupMessage(456088603, mc);
    }

}
